﻿using System;
using System.Collections.Generic;
using TFramework.ECS.Component;

namespace TFramework.ECS.Entity
{
    public interface IEntity : IDisposable
    {
        IObservable<int[]> ComponentsAdded { get; }

        IObservable<int[]> ComponentsRemoving { get; }

        IObservable<int[]> ComponentsRemoved { get; }

        int Id { get; }

        IEnumerable<IComponent> Components { get; }

        IReadOnlyList<int> ComponentAllocations { get; }

        void RemoveComponents(params Type[] componentsTypes);

        void RemoveAllComponents();

        IComponent GetComponent(Type componentType);

        IComponent GetComponent(int componentTypeId);

        ref T GetComponent<T>(int componentTypeId) where T : IComponent;

        ref T AddComponent<T>(int componentTypeId) where T : IComponent, new();

        void UpdateComponent<T>(int componentTypeId, T newValue) where T : struct, IComponent;

        bool HasComponent(Type componentType);

        bool HasComponent(int componentTypeId);

        void AddComponents(IReadOnlyList<IComponent> components);
        void RemoveComponents(IReadOnlyList<int> componentsTypeIds);
    }
}
